package cn.sdhuijin.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author sunp@sdhuijin.cn
 * @version 创建时间：2015年4月29日 上午10:21:27 类说明
 */

@Entity
@Table(name = "target")
public class Target extends IdEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	private String name;
	
	private int level;	//等级  1代表大队，0代表其他

	@ManyToOne
	@JoinColumn(name = "parent_id")
	private Target parent;

	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "parent", fetch = FetchType.LAZY)
	private List<Target> son;

	@ManyToMany(cascade = { CascadeType.ALL }, mappedBy = "targets", fetch = FetchType.LAZY)
	private List<Type> types;

	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "target", fetch = FetchType.LAZY)
	private List<Deduction> deduction;

	@ManyToOne
	private Standard standard;
	
	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "target", fetch = FetchType.LAZY)
	private List<ExtraScore> extraScore;

	/**
	 * @return the parent
	 */
	public Target getParent() {
		return parent;
	}

	/**
	 * @param parent
	 *            the parent to set
	 */
	public void setParent(Target parent) {
		this.parent = parent;
	}

	/**
	 * @return the son
	 */
	public List<Target> getSon() {
		return son;
	}

	/**
	 * @param son
	 *            the son to set
	 */
	public void setSon(List<Target> son) {
		this.son = son;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the deduction
	 */
	public List<Deduction> getDeduction() {
		return deduction;
	}

	/**
	 * @param deduction
	 *            the deduction to set
	 */
	public void setDeduction(List<Deduction> deduction) {
		this.deduction = deduction;
	}

	/**
	 * @return the standard
	 */
	public Standard getStandard() {
		return standard;
	}

	/**
	 * @param standard
	 *            the standard to set
	 */
	public void setStandard(Standard standard) {
		this.standard = standard;
	}
	

	/**
	 * @return the types
	 */
	public List<Type> getTypes() {
		return types;
	}

	/**
	 * @param types the types to set
	 */
	public void setTypes(List<Type> types) {
		this.types = types;
	}

	/**
	 * @return the level
	 */
	public int getLevel() {
		return level;
	}

	/**
	 * @param level the level to set
	 */
	public void setLevel(int level) {
		this.level = level;
	}

}
